<template>
  <div class="home">
    <!-- 表格 -->
    <div class="table_box">
      <el-table
        border
        height="295"
        v-loading="loading"
        :header-cell-style="tableHeader"
        ref="multipleTable"
        :data="tableInfo"
        tooltip-effect="dark"
        style="width: 100%;">
        <el-table-column
          width="160"
          sortable
          prop="modifyTime"
          label="修改时间">
          <template slot-scope="scope">
            <p style="text-align: left">{{formatTime(scope.row.modifyTime)}}</p>
          </template>
        </el-table-column>
        <el-table-column
          width="120"
          prop="operateUserName"
          label="操作人">
          <template slot-scope="scope">
            <p>{{ scope.row.operateUserName?scope.row.operateUserName:'——'}}</p>
          </template>
        </el-table-column>
        <el-table-column
          width="120"
          prop="userName"
          label="用户名">
          <template slot-scope="scope">
            <p>{{ scope.row.userName?scope.row.userName:'——'}}</p>
          </template>
        </el-table-column>
        <el-table-column
          prop="content"
          label="操作内容">
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>

import commons from "@/utils/common";
import { returnLog } from "@/api/data/user/productReturn";

export default {
    props:['orderId','userId','isUpdate'],
    data() {
      return {
        loading: false,
        tableInfo:[],
      }
    },
    mounted() {
      this.getTableInfo();
    },
    methods: {
      // 获取列表信息
      getTableInfo() {
        let that = this;
        that.loading = true;
          let queryParams = {
          userId:that.userId,
          returnNo:that.orderId
        }
        returnLog(queryParams).then(res => {
          that.tableInfo = res?res:[];
          that.loading = false;
        }).catch((e) => {
          that.loading = false;
        });
      },

      formatTime(time){
        return commons.formatTime(time)
      },


      // 设置table标题居中
      tableHeader({row, column, rowIndex, columnIndex}) {
        return 'background:#F0F2F5;color:#111;padding:10px 0;font-size:14px;font-weight:600'
      },
    },
    watch:{
      orderId(newD,oldD){
        this.getTableInfo()
      },
      isUpdate(newU,oldU) {
        // 获取更新后的列表
        this.getTableInfo();
      }
    }
  }
</script>

<style scoped>
.home {
  padding-left: 20px;
}
</style>
